<?php if (!defined('BASEPATH'))  exit('No direct script access allowed');
/**
 * @filesource goods_grid_form.php
 */
if(0){?><script><?php }?>
var list_user_ds = Ext.create('Ext.data.Store', {
    fields: [ 'id','departmentid', 'positionid', 'teamid', 'worknum',  
            'name', 'tel', 'sex', 'level', 'department_name',
            'position_name', 'team_name', 'entrytime'],
    pageSize: Hydcrm.CONF.GRID_PAGE_SIZE,
    proxy: {
        type: 'ajax',
        url: Hydcrm.CONF.CONN_URL,
        extraParams: {
            module: 'user',            
            action: 'list_user'
        },
        reader: {
            type: 'json',
            root: Hydcrm.CONF.JSON_READER_ROOT,
            totalProperty: Hydcrm.CONF.JSON_READER_TOTAL_PROPERTY
        }
    },
    autoLoad: true
});
var list_user_quit_ds = Ext.create('Ext.data.Store', {
    fields: [ 'id','departmentid', 'positionid', 'teamid', 'worknum',  
            'name', 'tel', 'sex', 'level', 'department_name',
            'status','position_name', 'team_name', 'entrytime'],
    pageSize: Hydcrm.CONF.GRID_PAGE_SIZE,
    proxy: {
        type: 'ajax',
        url: Hydcrm.CONF.CONN_URL,
        extraParams: {
            module: 'user',
            controller: 'user_quit',
            action: 'list_user'
        },
        reader: {
            type: 'json',
            root: Hydcrm.CONF.JSON_READER_ROOT,
            totalProperty: Hydcrm.CONF.JSON_READER_TOTAL_PROPERTY
        }
    },
    autoLoad: true
});


var onsearchUser = function(){
    var filter = Ext.getCmp('search').getValue() || null;
    list_user_ds.getProxy().extraParams['search_type'] = 'text';     
    list_user_ds.getProxy().extraParams['search_content'] = filter;
    list_user_ds.load();
};

var showAddEditWindowUser = function(id){ //alert(id);
    var title = "添加员工";
    var winid = 'add_window_user';
    if(id>0){
        title = '查看员工信息';
        winid = 'edit_window_user_'+id;
    }
    var win = Ext.getCmp(winid);
    if (!win) {
        win = Ext.create('widget.window', {
            title: title,
            header: {
                titlePosition: 2,
                titleAlign: 'center'
            },
            id: winid,
            closable: true,
            //closeAction: 'hide',
            maximizable: true,
            //animateTarget: Ext.get('user_info_add_window'),
            width: 600,
            minWidth: 350,
            height: 500,
            tools: [{type: 'pin'}],
            layout: {
                type: 'border',
                padding: 5
            },
            items: [ new Hydcrm.user.UserForm({userid:id})]
        });
        win.show();
    }
};
